#include <stdio.h>
int main()
{
    int n = 0, i = 0,t,sum;
    scanf("%d",&t);
    for (n = 2; n <t; n++)
    {
        sum = 0;
        for (i = 1; i < n; i++)
        {
            if (n%i == 0)
                sum += i;
        }
        if(sum == n)
        {
            printf("\n%5d\n",n);
            for (i = 1; i < n; i++)
            {
                if(n%i == 0)
                    printf("%5d", i);
            }
        }
    }
}
